package cate.game.role.res.worldtree.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBWorldTree;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "世界树根据英雄uid下阵的请求")
public class HeroShareDelUidReq implements MsgInput {
    @NoteField(value = "英雄uid")
    public String heroUid;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<Integer> rr = cc.getRole().getRes().worldTree.heroShare.delHeroShare(heroUid);
        if (rr.ok()) {
            Hero hero = cc.getRole().getRes().worldTree.heroShare.update2ClientByOnlyId(heroUid);
            cc.sendNow(new HeroShareDelResp(rr.data, heroUid, hero));
            cc.getRole().getBase().updatePower();
            cc.sendNow(new HeroShareDataResp(cc.getRole().getRes().worldTree.heroShare));
        } else {
            game.notice.message(cc.getRole(), rr.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBWorldTree.DEL_SHARE_UID_REQ;
    }
}
